﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufInputControl.h"

namespace gnuf {
    class Info;

    class GNUF_BASE_EXPORT ICheckControlHandler
        : public IInputControlHandler
    {
    public:
        virtual void onCheckStateChanged(bool) = 0;
    };
    
    class GNUF_BASE_EXPORT CheckControlAdpatation
        : public InputControlAdaptation
    {
    protected:
        CheckControlAdpatation(bool isRadio = false);
        virtual ~CheckControlAdpatation();

        //
        // Inherits from InputControlAdaptation...
        virtual void onVisibilityChanged(bool) override {}
        virtual void onSelectionChanged(bool) override {}
        
    public:
        virtual void onCheckStateChanged(bool) = 0;
    };
    
    class GNUF_BASE_EXPORT CheckControl
        : public InputControl
    {
        CANNOT_COPY_OR_ASSIGN(CheckControl)
    public:
        static const EItemType Type;
        CheckControl(ICheckControlHandler *, gcmp::OwnerPtr< Info > &);
        virtual ~CheckControl();

        inline const Info * info() const { return m_info.get(); }
        
        void check(bool, const CheckControlAdpatation * trigger = nullptr);

    private:
        gcmp::OwnerPtr< Info > m_info;
    };

    class GNUF_BASE_EXPORT RadioControl
        : public InputControl
    {
        CANNOT_COPY_OR_ASSIGN(RadioControl)
    public:
        static const EItemType Type;
        RadioControl(ICheckControlHandler *, gcmp::OwnerPtr< Info > &);
        virtual ~RadioControl();

        inline const Info * info() const { return m_info.get(); }

        void check(bool, const CheckControlAdpatation * trigger = nullptr);

    private:
        gcmp::OwnerPtr< Info > m_info;
    };

}
